<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<strong>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
</strong>

<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>拍卖会管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/xAdmin/css/font.css">
    <link rel="stylesheet" href="/xAdmin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/xAdmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/xAdmin/js/xadmin.js"></script>

    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">拍卖会管理</a>
            <a href="">拍卖会</a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
<%--                        <div class="layui-inline layui-show-xs-block">--%>
<%--                            <input type="text" class="layui-input"  autocomplete="off" placeholder="作品编号" name="artcode" id="artcode">--%>
<%--                        </div>--%>
<%--                        <div class="layui-inline layui-show-xs-block">--%>
<%--                            <input type="text" name="name" id="name" placeholder="作者名称" autocomplete="off" class="layui-input">--%>
<%--                        </div>--%>
<%--                        <div class="layui-inline layui-show-xs-block">--%>
<%--                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>--%>
<%--                        </div>--%>
                    </form>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="openW('/tBizAuction/editInit','新增')"><i class="layui-icon"></i>添加</button>
                </div>
                <div class="layui-card-body ">
                    <input type="hidden" value="${result.pageNum}" id="pageNum">
                    <input type="hidden" value="${result.pageSize}" id="pageSize">
                    <input type="hidden" value="${result.totalSize}" id="totalSize">
                    <input type="hidden" value="${result.totalPages}" id="totalPages">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>拍卖行名称</th>
                            <th>图片</th>
                            <th>开始时间</th>
                            <th>结束时间</th>
                            <th>操作</th>
                        </thead>
                        <tbody id="tBizArtList">
                        <c:forEach items="${result.content}" var="auc">
                        <tr>
                            <td>${auc.auctionname}</td>
                            <td><img src="${auc.posterPictureShow}"></td>
                            <td>${auc.stateTimeDesc}</td>
                            <td>${auc.endTimeDesc}</td>
                            <td class="td-manage">
                                <a title="编辑"  href="javascript:;" onclick="openW('/tBizAuction/editInit?id='+${auc.id},'修改')" >
                                    <i class="layui-icon">&#xe642;</i>
                                </a>
                                <a title="删除"  href="javascript:;" onclick="delAll('/tBizAuction/del?auctionid=${auc.auctionid}')">
                                    <i class="layui-icon">&#xe640;</i>
                                </a>
                                <a title="添加"  href="javascript:;"  data-id="${auc.auctionid}" onclick='openL(this,"添加作品")'>
                                    <i class="layui-icon">&#xe642;</i>
                                </a>
                            </td>
                        </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page" id="page">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
            ,layer = layui.layer;
        laypage.render({
            elem:'page'
            ,count:$('#totalSize').val()
            ,limit: $('#pageSize').val()
            ,groups: 5
            ,curr:$('#pageNum').val()
            ,first: 1
            ,last: $('#totalPages').val()
            ,jump: function(obj, first){
                //首次不执行
                if(!first){
                    window.location.href = "/tBizAuction/list?pageNum="+obj.curr+"&pageSize="+obj.limit;
                }

            }
        });
    });
    function openW(URL,title){
        console.log(URL);
        layui.use('layer', function(){
            var layer = parent.layui.layer;
            var index = layer.open({
                title: title,
                type: 2,
                area: ["900px","700px"],
                content: URL,
                end: function () {
                    console.log("回调成功");
                    refreshTable();
                }
            });
        });
    }

    function openL(obj,title){
       var URL ='/tBizAuction/aalist?auctionid='+$(obj).attr('data-id')+"&pageNum=1&pageSize=10";
        layui.use('layer', function(){
            var layer = parent.layui.layer;
            var index = layer.open({
                title: title,
                type: 2,
                area: ["900px","700px"],
                content: URL,
                end: function () {
                    console.log("回调成功");
                    refreshTable();
                }
            });
        });
    }


    function refreshTable(){
        window.location.reload();
    }


    function delAll (url) {
        $.ajax({
            url:url,
            type:'GET',
            dataType:'text',
            contentType: 'application/json',
            timeout:2000,
            success:function(data){
                var datas =JSON.parse( data );
                var layer = parent.layui.layer;
                if(datas.oper_res == 'success')
                    layer.msg('操作成功!',{icon:1,time:1000});
                else
                    layer.msg('操作失败!',{icon:1,time:1000});
                refreshTable();
            },
            error:function () {
                var layer = parent.layui.layer;
                layer.msg("操作失败",{icon:1,time:1000});
            }
        });
    }
</script>
</html>
